package cn.liuyiyou.lean.es.config;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchCustomConversions;
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;

/**
 * TODO
 *
 * @author liuyiyou
 * @version 1.0
 * @date 2021/8/4 21:37
 */
@Configuration
public class ElasticSearchTemplateConfig {

    @Bean
    public MappingElasticsearchConverter mappingElasticsearchConverter(SimpleElasticsearchMappingContext mappingContext, BeanFactory beanFactory) {

        MappingElasticsearchConverter mappingElasticsearchConverter = new MappingElasticsearchConverter(mappingContext);
        mappingElasticsearchConverter.setConversions(beanFactory.getBean(ElasticsearchCustomConversions.class));
        return mappingElasticsearchConverter;
    }
}
